home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Information / Digests / CSMP Digest / volume 1 / csmp-v1-203.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  47.1 KB  |  1,262 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Mon, 02 Nov 92       Volume 1 : Issue 203
  2.  
  3. Today's Topics:
  4.  
  5.     Formatting a disk in the background
  6.     TCL/UnloadSeg Help Needed
  7.     ProcPtr, how to call Proc pointed to?
  8.     Unloading Segments
  9.     Get sender address from an AppleEvent
  10.     GrowZone & A5
  11.     Measuring text in different fonts
  12.     MacTCPCommonTypes & typedef unsigned char b_8.
  13.     Postscript downloading.
  14.     popup menus in non-system font
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  19.  
  20. The digest is a collection of article threads from the internet newsgroup
  21. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  22. regularly and want an archive of the discussions.  If you don't know what a
  23. newsgroup is, you probably don't have access to it.  Ask your systems
  24. administrator(s) for details.  (This means you can't post questions to the
  25. digest.)
  26.  
  27. Each issue of the digest contains one or more sets of articles (called
  28. threads), with each set corresponding to a 'discussion' of a particular
  29. subject.  The articles are not edited; all articles included in this digest
  30. are in their original posted form (as received by our news server at
  31. cs.uoregon.edu).  Article threads are not added to the digest until the last
  32. article added to the thread is at least one month old (this is to ensure that
  33. the thread is dead before adding it to the digest).  Article threads that
  34. consist of only one message are generally not included in the digest.
  35.  
  36. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  37. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  38. file /pub/mac/csmp-digest/README before downloading any files.  The most
  39. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  40. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  41. archive has a mail server; send a message with the text '$MACarch help' (no
  42. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  43.  
  44. The digest is also available via email.  Just send a note saying that you
  45. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  46. automatically receive each new issue as it is created.  Sorry, back issues
  47. are not available through the mailing list.
  48.  
  49. Send administrative mail to mkelly@cs.uoregon.edu.
  50.  
  51.  
  52. -------------------------------------------------------
  53.  
  54. From: peterbak@microsoft.com (Peter Bako)
  55. Subject: Formatting a disk in the background
  56. Date: 31 Aug 92 22:30:46 GMT
  57. Organization: Microsoft Corp.
  58.  
  59.  
  60. I have a small application that automatically formats disk, but
  61. can only do so while it is in the foreground.  How can I make
  62. the program be able to format a disk in the background?  Either
  63. by running the program in the background, or to move it there once
  64. it has started its process.
  65.  
  66. Thanks,
  67.  
  68. Peter
  69.  
  70. - -- 
  71. (*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\/-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)
  72. (   UUCP:         peterbak@microsoft  ||   Is this all that I am?  Is there   )
  73. (   CompuServe:   71170,1426          ||   nothing more?    - V'ger           )
  74. (*)-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/\-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+(*)
  75.  
  76. +++++++++++++++++++++++++++
  77.  
  78. From: reed@snake.tc.cornell.edu (Michael G. Reed)
  79. Date: 1 Sep 92 12:12:35 GMT
  80. Organization: Cornell National Supercomputing Facility
  81.  
  82. In article <1992Aug31.223046.8274@microsoft.com>, peterbak@microsoft.com (Peter Bako) writes:
  83. |> 
  84. |> I have a small application that automatically formats disk, but
  85. |> can only do so while it is in the foreground.  How can I make
  86. |> the program be able to format a disk in the background?  Either
  87. |> by running the program in the background, or to move it there once
  88. |> it has started its process.
  89. |> 
  90. I don't think it can be done.  The problem is that reads/writes to floppy 
  91. disks are VERY time critical.  Therefore, most OS's will disable interupts
  92. and require the formatting code to run exclusively if you want a "properly"
  93. formatted disk.  This happens on the mac (that's why the mouse "jumps" when
  94. you are formatting disks...the mouse is interupt driven), so I don't think 
  95. you're going to be able to get around it with Apple's routines...You could
  96. always write your own disk I/O routines :) (just kidding).
  97.  
  98. - -Michael
  99.  
  100. - -----------------------------------------------------------------------------
  101. Michael G. Reed                                  (reed@Theory.TC.Cornell.edu)
  102. Cornell National Supercomputing Facility                       (607)/254-8806
  103. - -----------------------------------------------------------------------------
  104.         Why be normal, it's boring; and boring people should be shot.
  105.  
  106. Note:  These are not the views of my employer (and probably not mine either).
  107.  
  108. +++++++++++++++++++++++++++
  109.  
  110. From: Quinn <quinn@cs.uwa.edu.au>
  111. Organization: The University of Western Australia
  112. Date: Wed, 2 Sep 1992 01:28:22 GMT
  113.  
  114. In article <1992Sep1.121235.11175@tc.cornell.edu> Michael G. Reed,
  115. reed@snake.tc.cornell.edu writes:
  116. >I don't think it can be done.  The problem is that reads/writes to
  117. floppy 
  118. >disks are VERY time critical.  Therefore, most OS's will disable
  119. interupts
  120. >and require the formatting code to run exclusively if you want a
  121. "properly"
  122. >formatted disk.  This happens on the mac (that's why the mouse "jumps"
  123. when
  124. >you are formatting disks...the mouse is interupt driven), so I don't
  125. think 
  126. >you're going to be able to get around it with Apple's routines...You
  127. could
  128. >always write your own disk I/O routines :) (just kidding).
  129.  
  130. Unless you've got a IIfx (or Quadra 900/950 ?) because the on-board
  131. IO Processors handle all that messing around with floppies and leave
  132. the mouse tracking smooth as silk.  [Heavy sigh]
  133.  
  134. Of course hacking the disk initialisation package to run in the
  135. background would be fun (-;
  136.  
  137. btw Does anyone know why the disk init package doesn't display
  138. a filler bar telling you how far it's got?  It seems like a user
  139. interface faux pas to me.
  140.  
  141. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  142. Department of Computer Science, The University of Western Australia
  143.   -- Inquiring minds want to know where the phrase "Inquiring minds
  144.      want to know" comes from.
  145.  
  146. +++++++++++++++++++++++++++
  147.  
  148. From: mikeh@kralizec.zeta.org.au (Michael Hore)
  149. Date: 30 Sep 92 09:27:47 GMT
  150. Organization: Kralizec Dialup Unix Sydney: +61-2-837-1183 V.32
  151.  
  152.  
  153. Quinn "The Eskimo!" writes:
  154.  
  155. >btw Does anyone know why the disk init package doesn't display
  156. >a filler bar telling you how far it's got?  It seems like a user
  157. >interface faux pas to me.
  158.  
  159. I'd agree with that.  As far as I remember the user interface to the
  160. DIP has hardly changed since System 1!  Of course the rest of the
  161. package has evolved to handle HD disks, mapping out of bad blocks
  162. under Sys 7, and so on, but not the interface.
  163.  
  164. I think it was probably just so low on the priority list that it
  165. sort of dropped off the bottom without anyone noticing :-)
  166.  
  167. - -- Mike.
  168.  
  169. - --------------------------------------------------------
  170. Mike Hore        Internet:    mikeh@kralizec.zeta.org.au
  171.  
  172. ---------------------------
  173.  
  174. From: cfpdh@ux1.cts.eiu.edu (Peter Hesterman)
  175. Subject: TCL/UnloadSeg Help Needed
  176. Date: 25 Sep 92 14:23:16 GMT
  177. Organization: Eastern Illinois University
  178.  
  179. My TCL project includes numerous segments which contain only code
  180. associated with TCL objects that are infrequently used by the program.  In
  181. the event of a memory shortage, I would like to mark these code segments
  182. as purgeable.  Is it possible to identify one of the methods belonging to
  183. one of the objects as the argument for UnloadSeg()?  I have tried
  184. something like UnloadSeg(MyObject::IMyObject) but got a access denied
  185. error.  UnloadSeg(IMyObject) didn't work at all.  My work-around has been
  186. to add a dummy file containing a dummy function to each of these segments
  187. and then UnloadSeg(Dummy).  Have I missed the boat here, is there a more
  188. elegant way of doing it, etc.?
  189.  
  190. Thanks in advance.
  191.  
  192. Peter Hesterman
  193. cfpdh@eiu.edu
  194.  
  195. +++++++++++++++++++++++++++
  196.  
  197. From: tree@kira.uvm.edu (Tom Emerson)
  198. Date: 28 Sep 92 12:32:40 GMT
  199. Organization: University of Vermont, EMBA Computer Facility
  200.  
  201. In article <1992Sep25.142316.21541@ux1.cts.eiu.edu> cfpdh@ux1.cts.eiu.edu (Peter Hesterman) writes:
  202.  
  203.    My TCL project includes numerous segments which contain only code
  204.    associated with TCL objects that are infrequently used by the program.  In
  205.    the event of a memory shortage, I would like to mark these code segments
  206.    as purgeable.  Is it possible to identify one of the methods belonging to
  207.    one of the objects as the argument for UnloadSeg()?  I have tried
  208.    something like UnloadSeg(MyObject::IMyObject) but got a access denied
  209.    error.  UnloadSeg(IMyObject) didn't work at all.  My work-around has been
  210.    to add a dummy file containing a dummy function to each of these segments
  211.    and then UnloadSeg(Dummy).  Have I missed the boat here, is there a more
  212.    elegant way of doing it, etc.?
  213.  
  214. The dummy function technique is the easiest to implement. You could also write
  215. code to unload segments a la MacApp, i.e. mark a group to be unloaded each
  216. time through the event loop. If you know the name (or number) of each segment
  217. (each is called Segx, where x is between 2 and 2+the number of segments in
  218. your project. The first segment in your project window is segment 2) you can
  219. get a handle to them with GetResource (or GetNamedResource), add the first
  220. word of resource (the offset to that segments JT entry), then add the
  221. appropriate offsets (I think its A5+32+2, i.e. the value of A5 plus the offset
  222. to the beginning of the jump table plus the two bytes for the JUMP in the JT
  223. entry). You could write this has a chore that will unload your segments during
  224. idleProc time.
  225.  
  226. Tom
  227. - --
  228.    Tom Emerson                                    Technical Support
  229.    Language Products Group                     Symantec Corporation
  230.             Internet: tree@uvm.edu
  231.  
  232. ---------------------------
  233.  
  234. From: sinteur@ooc.uva.nl (John Sinteur)
  235. Subject: ProcPtr, how to call Proc pointed to?
  236. Date: 25 Sep 92 14:47:31 GMT
  237. Organization: ooc.uva.nl
  238.  
  239. What I need in a piece of pascal code is to call the procedure
  240. pointed to by a ProcPtr (one of the parameters to the proceudure).
  241.  
  242. Now I seem to remember seeing this discussed a while ago, but can't find
  243. a reference to it.
  244.  
  245. Can anybody help me out?
  246.  
  247. - -John
  248.  
  249. - -- 
  250. [ sinteur@ooc.uva.nl   John Sinteur, 2:512/48 (fidonet) ]
  251. [   Snail: Jade str 28, 2332 RT Leiden, The Netherlands ]
  252. [         Fra der kracht der duken ud der liga          ]
  253.  
  254. +++++++++++++++++++++++++++
  255.  
  256. From: tholle16@ursa.calvin.edu (Tim Hollebeek)
  257. Date: 25 Sep 92 16:06:30 GMT
  258. Organization: Calvin College
  259.  
  260. sinteur@ooc.uva.nl (John Sinteur) writes:
  261.  
  262. >What I need in a piece of pascal code is to call the procedure
  263. >pointed to by a ProcPtr (one of the parameters to the proceudure).
  264.  
  265. The best way to do it is to write some inline code to do it ...
  266.  
  267. procedure Call(p:ProcPtr);
  268. {
  269.   move.l (a7)+,a0
  270.   jmp    (a0)
  271. }
  272. inline $xxxx,$xxxx,$xxxx;
  273.  
  274. unfortunately I don't have a mac here or a list of opcodes, but it works
  275. well; several of my programs have used this strategy to simulate some of
  276. the aspects of Object Pascal in regular pascal.
  277.  
  278.  
  279. - --
  280. - ------------------------------------------------------------------------------
  281. Tim Hollebeek      ---     tholle16@usurp.calvin.edu
  282. - ------------------------------------------------------------------------------
  283. Hi! I'm not a real .signature virus ... but I play one on the net.
  284.  
  285. +++++++++++++++++++++++++++
  286.  
  287. From: rson@rhi.hi.is (Mimir Reynisson)
  288. Date: 29 Sep 92 10:05:05 GMT
  289.  
  290.  
  291. SOmething like
  292.  
  293. static pascal Boolean DoProc(long param1, long param2, .. etc .. ProcPtr proc)
  294.  = {0x205F, 0x4E90};
  295.  
  296. This will pop the ProcPtr parameter of the stack and then JSR to it
  297.  
  298. ---------------------------
  299.  
  300. From: sc@argentic.gts.org (Sterling Chipperfield)
  301. Subject: Unloading Segments
  302. Date: 25 Sep 92 13:16:09 GMT
  303. Organization: Argentic BBS [Toronto, Ontario, Canada]
  304.  
  305. I had a program set up so that each procedure was in a difference code
  306. segment.  After the main event loop, I had each segment "unloaded".  Why
  307. is it that some of the procedures worked fine, while others did not.  When 
  308. I removed the unloading portion of the program, everything seemed to run
  309. smoothly.  Any ideas? Does one have to check that the segment is loaded
  310. before calling the unload command or does the computer know not to unload
  311. a segment that is not already there?
  312.  
  313.  
  314. Sterling Chipperfield <sc@argentic.gts.org> OR <sc@argentic.uucp>
  315.  
  316. +++++++++++++++++++++++++++
  317.  
  318. From: tree@kira.uvm.edu (Tom Emerson)
  319. Date: 28 Sep 92 12:37:48 GMT
  320. Organization: University of Vermont, EMBA Computer Facility
  321.  
  322. In article <1791@argentic.gts.org> sc@argentic.gts.org (Sterling Chipperfield) writes:
  323.  
  324.    I had a program set up so that each procedure was in a difference code
  325.    segment.  After the main event loop, I had each segment "unloaded".  Why
  326.    is it that some of the procedures worked fine, while others did not.  When 
  327.    I removed the unloading portion of the program, everything seemed to run
  328.    smoothly.  Any ideas? Does one have to check that the segment is loaded
  329.    before calling the unload command or does the computer know not to unload
  330.    a segment that is not already there?
  331.  
  332. Calling unload seg on an unloaded segment is effectively a nop; it doesn't
  333. cause a problem. You can run into problems if a segment is unloaded and
  334. purged, and then a function attempts to return to a function in a purged
  335. segment: the return address is on the stack, and the return doesn't go through
  336. the jump table and you shoot off into random data. Messy.
  337.  
  338. Tom
  339. - --
  340.    Tom Emerson                                    Technical Support
  341.    Language Products Group                     Symantec Corporation
  342.             Internet: tree@uvm.edu
  343.  
  344. ---------------------------
  345.  
  346. From: trinkad@fog.cs.orst.edu (Darald Trinka)
  347. Subject: Get sender address from an AppleEvent
  348. Date: 25 Sep 92 18:12:33 GMT
  349. Organization: OSU
  350.  
  351.  
  352.   Can some one tell me if this is the correct way to get the
  353. sender's address out of an AppleEvent so I send a message back at some 
  354. latter time.  
  355.  
  356.  
  357. extern AEDesc replyAddress;        /* Global */
  358.  
  359. pascal OSErr MyHandleShowText(theAppleEvent, reply, handlerRefcon)
  360. AppleEvent  theAppleEvent,reply; 
  361. long  handlerRefcon;
  362. {
  363. OSErr  myErr;
  364. DescType  typeCode;
  365. int  sessionRefNum;
  366.  
  367. ...    < some code taken out >
  368.  
  369. /* get session ref number */
  370. myErr = AEGetAttributePtr(&theAppleEvent, keyEventSourceAttr, 
  371.   typeShortInteger, &typeCode, (Ptr) &sessionRefNum, sizeof(int),
  372.   &actualSize);
  373. if (myErr != noErr) DoError(myErr);
  374. /* generate AEDesc from sessionRefNum */
  375. myErr = AECreateDesc(typeSessionID, (Ptr) &sessionRefNum, 
  376.   sizeof( PPCSessRefNum), &replyAddress);
  377. if (myErr != noErr) DoError(myErr);
  378.  
  379.  
  380. ... < more code >
  381.  
  382. +++++++++++++++++++++++++++
  383.  
  384. From: grobbins@Apple.COM (Grobbins)
  385. Date: 27 Sep 92 22:33:15 GMT
  386. Organization: Apple Computer Inc., Cupertino, CA
  387.  
  388. In article <1992Sep25.181233.28698@CS.ORST.EDU> trinkad@fog.cs.orst.edu (Darald Trinka) writes:
  389. >  Can some one tell me if this is the correct way to get the
  390. >sender's address out of an AppleEvent so I send a message back at some 
  391. >latter time.  
  392. >
  393. >myErr = AEGetAttributePtr(&theAppleEvent, keyEventSourceAttr, 
  394. >  typeShortInteger, &typeCode, (Ptr) &sessionRefNum, sizeof(int),
  395. >  &actualSize);
  396.  
  397. The event source attribute is a number indicating how the event
  398. was transmitted (directly from the same process, from another
  399. process on the machine, and so forth.)  It is a short containing
  400. the equivalent of an enumerated from this list (taken from
  401. AppleEvents.p):
  402.  
  403.      AEEventSource = (kAEUnknownSource, kAEDirectCall, kAESameProcess, 
  404.                       kAELocalProcess, kAERemoteProcess);
  405.  
  406. This event source information is rarely useful.
  407.  
  408. To find the sender of an Apple event, use AEGetAttributePtr to extract
  409. the address attribute (keyAddressAttr) of the event.  It will be a
  410. process serial number or target ID.  Use the same buffer (and the same
  411. data type) to later create a new address descriptor.  This is discussed
  412. on page 107 of issue 10 of develop magazine.
  413.  
  414. Grobbins        grobbins@apple.com
  415.  
  416. Usual disclaimers apply.
  417.  
  418. +++++++++++++++++++++++++++
  419.  
  420. From: lai@Apple.COM (Ed Lai)
  421. Date: 28 Sep 92 16:38:08 GMT
  422. Organization: Apple Computer Inc., Cupertino, CA
  423.  
  424. >myErr = AEGetAttributePtr(&theAppleEvent, keyEventSourceAttr,
  425. >  typeShortInteger, &typeCode, (Ptr) &sessionRefNum, sizeof(int),
  426. >  &actualSize);
  427.  
  428. Event source just classify where the event is coming from (local, remote etc). 
  429.  
  430. You want to get it using the keyword keyAddressAttr, ask for typeTargetID,
  431. but just the fact that the session id is the first 4 bytes of a target ID, so
  432. you can ask for just four bytes.
  433.  
  434. /* Disclaimer: All statments and opinions expressed are my own */
  435. /* Edmund K. Lai                                               */
  436. /* Apple Computer, MS37-UP                                     */
  437. /* 20525 Mariani Ave,                                          */
  438. /* Cupertino, CA 95014                                         */
  439. /* (408)974-6272                                               */
  440. zW@h9cOi
  441.  
  442. ---------------------------
  443.  
  444. From: liaj0032@ac.dal.ca
  445. Subject: GrowZone & A5
  446. Date: 17 Sep 92 01:59:23 GMT
  447. Organization: Dalhousie University, Halifax, Nova Scotia, Canada
  448.  
  449. This is a question which I posed on a local bulletin board, but to which
  450. I did not receive a satisfactory answer.
  451. My program uses a growZone function in case I am running out of heap space. In
  452. a tech note (i think it's #180), it says that A5 is not guaranteed to be
  453. pointing to the application's globals when GrowZone is called, since it could 
  454. be called by the system.
  455. It recommends in a tech note that SetUpA5 and RestoreA5 should be used to solve
  456. this problem. However, these two routines are later discouraged, having been
  457. replaced by SetA5 and SetCurrentA5, which do not however store A5 in a global
  458. memory location.
  459. Since GrowZone is not really called by the programmer, she or he is unable to
  460. use the trick advocated in the tech notes to get A5 to completion routines or 
  461. VBL routines by using the address of the parameter block to locate A5. Since
  462. GrowZone doesn't have a parameter block, and you, as programmer, don't call
  463. it anyways, how can you ensure that A5 points to your application's globals if
  464. your GrowZone routine is called!!??
  465. (p.s. this is the first time I've used internet, and my first time on vms in
  466. over six years so if something goes wonky here i'll get better!)
  467.  
  468. Thanks for the help. I'm sure this question has kept many programmers up at 
  469. night...
  470.  
  471. Sean McDowell
  472.  
  473. +++++++++++++++++++++++++++
  474.  
  475. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  476. Date: 25 Sep 92 23:02:52 GMT
  477. Organization: Kalamazoo College
  478.  
  479. liaj0032@ac.dal.ca writes:
  480. >It recommends in a tech note that SetUpA5 and RestoreA5 should be used to solve
  481. >this problem. However, these two routines are later discouraged, having been
  482. >replaced by SetA5 and SetCurrentA5, which do not however store A5 in a global
  483. >memory location.
  484.  
  485. Hmmmm...according to TN208, SetCurrentA5 just loads the contents of
  486. CurrentA5 into the A5 register.  I.e. it _does_ use the low-mem global.
  487. Look at the code on the last page of that note.
  488. - -- 
  489.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  490.  I'm your only friend, I'm not your only friend, but I'm a little glowing
  491.  friend, but really I'm not actually your friend, but I am...
  492.  
  493. +++++++++++++++++++++++++++
  494.  
  495. From: REEKES@applelink.apple.com (Jim Reekes)
  496. Date: 28 Sep 92 20:21:42 GMT
  497. Organization: Apple Computer, Inc.
  498.  
  499. In article <1992Sep16.225923.7580@ac.dal.ca>, liaj0032@ac.dal.ca wrote:
  500. > This is a question which I posed on a local bulletin board, but to which
  501. > I did not receive a satisfactory answer.
  502. > My program uses a growZone function in case I am running out of heap space. In
  503. > a tech note (i think it's #180), it says that A5 is not guaranteed to be
  504. > pointing to the application's globals when GrowZone is called, since it could 
  505. > be called by the system.
  506. > It recommends in a tech note that SetUpA5 and RestoreA5 should be used to solve
  507. > this problem. However, these two routines are later discouraged, having been
  508. > replaced by SetA5 and SetCurrentA5, which do not however store A5 in a global
  509. > memory location.
  510. > Since GrowZone is not really called by the programmer, she or he is unable to
  511. > use the trick advocated in the tech notes to get A5 to completion routines or 
  512. > VBL routines by using the address of the parameter block to locate A5. Since
  513. > GrowZone doesn't have a parameter block, and you, as programmer, don't call
  514. > it anyways, how can you ensure that A5 points to your application's globals if
  515. > your GrowZone routine is called!!??
  516. > (p.s. this is the first time I've used internet, and my first time on vms in
  517. > over six years so if something goes wonky here i'll get better!)
  518.  
  519. The routine below was taken from the MacDTS sample code SoundApp.
  520.  
  521. FUNCTION MyGrowZone(cbNeeded: Size): LONGINT;
  522.  
  523. {This is a very basic grow zone procedure.  My application keeps a reserve
  524.  handle of memory in case the Memory Manager gets a request for some memory
  525.  that is not available in my heap.  If memory were to get tight (<32k),
  526.  the Toolbox will crash the system, especially Quickdraw.  Before releasing
  527.  the reserve handle I make sure it isnUt the GZSaveHnd.  This handle cannot
  528.  be touched by the grow zone procedure.
  529.  
  530.  WARNING:  The grow zone procedure will be called and A5 may not be valid.
  531.  Read Tech Note #136 and 208}
  532.  
  533. VAR
  534.     theA5:      LONGINT;
  535.  
  536. BEGIN
  537.     theA5:= SetCurrentA5;
  538.     IF (gReserveMemory^ <> NIL) & (gReserveMemory <> GZSaveHnd) THEN BEGIN
  539.         EmptyHandle(gReserveMemory);
  540.         MyGrowZone:= kSizeOfReserve;                {released this much
  541. memory}
  542.     END ELSE
  543.         MyGrowZone:= 0;                             {this may release more
  544. memory}
  545.     theA5:= SetA5(theA5);
  546. END; {MyGrowZone}
  547.  
  548.  
  549. - -----------------------------------------------------------------------
  550. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  551.                              |          Sound Manager Expert
  552. Apple Computer, Inc.         | RAll opinions expressed are mine, and do
  553. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  554. Cupertino, CA 95014          |       employer, Apple Computer Inc.S
  555.  
  556. ---------------------------
  557.  
  558. From: mwu@orion.oac.uci.edu (Matt Wu)
  559. Subject: Measuring text in different fonts
  560. Organization: University of California, Irvine
  561. Date: 30 Sep 92 20:23:53 GMT
  562.  
  563.  
  564. I'm currently writing a program that will need to measure the width of
  565. text as it will appear on a written page.  I've been using the stringwidth
  566. function to do this.  However, as the Macintosh uses bit-mapped fonts,
  567. I was wondering how accurate this would be as compared to, say, final
  568. output out of a PostScript laserprinter?  If this is not a very accurate way
  569. of measuring text width, can you offer any suggestions as to how I could
  570. get better results?
  571.  
  572. Thanks,
  573.  
  574. Matt
  575. mwu@orion.oac.uci.edu
  576.  
  577. +++++++++++++++++++++++++++
  578.  
  579. From: de19@umail.umd.edu (Dana S Emery)
  580. Date: 1 Oct 92 02:10:44 GMT
  581. Organization: Personal
  582.  
  583. In article <2ACA0CD9.12346@news.service.uci.edu>, mwu@orion.oac.uci.edu
  584. (Matt Wu) wrote:
  585. > I'm currently writing a program that will need to measure the width of
  586. > text as it will appear on a written page.  I've been using the stringwidth
  587. > function to do this.  However, as the Macintosh uses bit-mapped fonts,
  588. > I was wondering how accurate this would be as compared to, say, final
  589. > output out of a PostScript laserprinter?  If this is not a very accurate way
  590. > of measuring text width, can you offer any suggestions as to how I could
  591. > get better results?
  592.  
  593. Matt, this is a rather large can of worms.
  594.  
  595. First, it is difficult for a program to know if a PS font will be used for
  596. imageing.  Second, the bitmap width tables are nowhere near as precise as
  597. the actual PS glyph tables, so that brings up the Q of obtaining better
  598. information (assuming you actually need it).  Third, all of this assumes
  599. that your code is aware of whatever kerning is going to be imposed.  One
  600. impractical strategy would be to attempt to debreif the actual PS font, but
  601. that involves access to it (printer/printer disk residency, maybe even
  602. remote print site) and considerable greif deencodeing it.  
  603.  
  604. A better strategy would be to reference the fonts AFM file which is
  605. available for all adobe (and many other) type 1 fonts.  I beleive adobe
  606. makes the afm and the bitmaps available essentially as freeware for all its
  607. fonts (but dont quote me), so it is not unreasonable to require that your
  608. users supply them.  One could also depend on the ATM programatic hooks,
  609. with the afm (and QD) as backup.
  610.  
  611. Currently, QD, TT, and PS fonts are supported.  PS differ from QD fonts in
  612. that they have an associated 'LWFN' file whose name is described by an
  613. optional table in the 'FOND' resource.  TT fonts are defined by an 'sfnt'
  614. resource which bundles both the bitmaps and the PS code.  Conceivably, a
  615. similar wrapper could be designed for PS fonts, but that is vaporware at
  616. the present.
  617.  
  618. So, your code has a text run which uses a given font/face/size, and you
  619. want to calculate its width.  You need to get access to the FOND resource,
  620. and debreif it to see if the PS name table exists (If not, use existing QD
  621. technology).  If PS, then check for ATM, and get it to measure the text for
  622. you.  If no ATM, then look for the relevant afm file, and parse it for the
  623. characters used.  A great deal of this is implemented by the LW driver,
  624. which you could explore with your fav disassembler.
  625.  
  626. Ref: IM 1, 4, 5, 6; revIM font chapter, in 'text' (i think); Adobe AFM
  627. specification;  Adobe ATM programmers hook stuf (sorry, I forget the
  628. official title).
  629.  
  630. You might want to read the comp.lang.postscript FAQ for info on dealing
  631. with the automated adobe technical document server, and the revIM font
  632. chapter can be gotten from ftp.apple.com, or from the ETO/develop CD-roms.
  633.  
  634. - --
  635.  
  636. Dana S Emery <de19@umail.umd.edu> | "Novo, de Novo,
  637.                                   |     de novo, de no-o-o-o-o---, 
  638.                                   | Novemba come an' dey gonna go home."
  639.  
  640. ---------------------------
  641.  
  642. From: David Johnston <davidj@daveland.demon.co.uk>
  643. Subject: MacTCPCommonTypes & typedef unsigned char b_8.
  644. Organization: Daveland Developments
  645. Date: Sat, 26 Sep 1992 17:33:24 GMT
  646.  
  647. I've been doing some 'Lets grope in the dark TCP programming' and
  648. have run up against a somewhat bizarre problem.
  649.  
  650.  To get started I tried to compile a piece of Apple code (I think
  651. from ftp.apple.com) called tcpserver what is a simple greeting
  652. server (Under Think C).
  653.  It fell over wanting MacTCPCommonTypes.h, so I found me a copy
  654. of this somewhere and stuck it in. It then fell over with
  655. "Illegal redeclaration of b_8"
  656. at the line "typedef unsigned char b_8" in MacTCPCommonTypes.h.
  657.  
  658. Fair enough, *except* I've scanned every last byte of my hard
  659. disk and can't find any file or library which refers to b_8.
  660.  
  661. How can I be redeclaring this? Why doesn't the rest of the world
  662. have this problem? And why aren't I more succesful with women?
  663. Are these problems linked? Inquring minds want to know.
  664.  
  665. - -----------------------------------------------------------------
  666. David Johnston:  davidj@daveland.demon.co.uk (Home IP connection)
  667. - -----------------------------------------------------------------
  668.  
  669. +++++++++++++++++++++++++++
  670.  
  671. From: de19@umail.umd.edu (Dana S Emery)
  672. Date: 27 Sep 92 14:48:53 GMT
  673. Organization: Personal
  674.  
  675. In article <Bv74rq.5EH@gate.demon.co.uk>, davidj@daveland.demon.co.uk
  676. (David Johnston) wrote:
  677.  
  678. [...]
  679.  
  680. >  It fell over wanting MacTCPCommonTypes.h, so I found me a copy
  681. > of this somewhere and stuck it in. It then fell over with
  682. > "Illegal redeclaration of b_8"
  683. > at the line "typedef unsigned char b_8" in MacTCPCommonTypes.h.
  684. > Fair enough, *except* I've scanned every last byte of my hard
  685. > disk and can't find any file or library which refers to b_8.
  686. > How can I be redeclaring this? Why doesn't the rest of the world
  687. > have this problem? And why aren't I more succesful with women?
  688. > Are these problems linked? Inquring minds want to know.
  689.  
  690. I have had some difficulty dealing with Thc 5.0.3 on a project started
  691. under 5.0.2, in my case the linker is declareing a symbol undefined which
  692. neither I nor Symantec DTS can locate.
  693.  
  694. I wonder if they test this stuff the same way we do?
  695.  
  696. - --
  697.  
  698. Dana S Emery <de19@umail.umd.edu> | "Novo, de Novo,
  699.                                   |     de novo, de no-o-o-o-o---, 
  700.                                   | Novemba come an' dey gonna go home."
  701.  
  702. +++++++++++++++++++++++++++
  703.  
  704. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  705. Date: 29 Sep 92 04:15:55 GMT
  706. Organization: University of Waikato, Hamilton, New Zealand
  707.  
  708. In article <Bv74rq.5EH@gate.demon.co.uk>, David Johnston <davidj@daveland.demon.co.uk> writes:
  709. > I've been doing some 'Lets grope in the dark TCP programming' and
  710. > have run up against a somewhat bizarre problem.
  711. >
  712. >  To get started I tried to compile a piece of Apple code (I think
  713. > from ftp.apple.com) called tcpserver what is a simple greeting
  714. > server (Under Think C).
  715. >  It fell over wanting MacTCPCommonTypes.h, so I found me a copy
  716. > of this somewhere and stuck it in. It then fell over with
  717. > "Illegal redeclaration of b_8"
  718. > at the line "typedef unsigned char b_8" in MacTCPCommonTypes.h.
  719. >
  720. > Fair enough, *except* I've scanned every last byte of my hard
  721. > disk and can't find any file or library which refers to b_8.
  722.  
  723. (Does a quick check) As I suspected--this is the first typedef in
  724. MacTCPCommonTypes.h.
  725.  
  726. What this means is that you must be #including MacTCPCommonTypes.h
  727. more than once, either directly or indirectly. Now all you have to do
  728. is track it down...
  729.  
  730. Lawrence "This would never happen with Modula-2" D'Oliveiro
  731. Usenet DBcc specialist
  732.  
  733. +++++++++++++++++++++++++++
  734.  
  735. From: de19@umail.umd.edu (Dana S Emery)
  736. Date: 28 Sep 92 16:04:30 GMT
  737. Organization: Personal
  738.  
  739. In article <de19-270992104602@mac19-pg2.umd.edu>, de19@umail.umd.edu (Dana
  740. S Emery) wrote:
  741. > In article <Bv74rq.5EH@gate.demon.co.uk>, davidj@daveland.demon.co.uk
  742. > (David Johnston) wrote:
  743. > [...]
  744. > I have had some difficulty dealing with Thc 5.0.3 on a project started
  745. > under 5.0.2, in my case the linker is declareing a symbol undefined which
  746. > neither I nor Symantec DTS can locate.
  747. > I wonder if they test this stuff the same way we do?
  748. > --
  749. > Dana S Emery <de19@umail.umd.edu>
  750.  
  751. As a follow up to the above, I must mention that the problem alluded to
  752. failed to replicate itself when I reconstructed the project file from
  753. scratch, implying that it had somehow become corrupted.
  754.  
  755. Since this presumed corruption affected a project which has never been
  756. executed, I am even more puzzled.
  757.  
  758. Stay tuned for further developments.
  759.  
  760. Oh, BTW, the symptom was a spurious link failure, referencing an
  761. (undefined) external symbol which n'exist pas, either in my code or in
  762. symantec's.
  763.  
  764. - --
  765.  
  766. Dana S Emery <de19@umail.umd.edu> | "Novo, de Novo,
  767.                                   |     de novo, de no-o-o-o-o---, 
  768.                                   | Novemba come an' dey gonna go home."
  769.  
  770. +++++++++++++++++++++++++++
  771.  
  772. From: moonshadow@cs.stanford.edu (Sean White)
  773. Organization: Stanford University CSLI
  774. Date: Mon, 28 Sep 1992 18:47:15 GMT
  775.  
  776. In article <1992Sep28.161555.11063@waikato.ac.nz> ldo@waikato.ac.nz  
  777. (Lawrence D'Oliveiro, Waikato University) writes:
  778. > In article <Bv74rq.5EH@gate.demon.co.uk>, David Johnston  
  779. <davidj@daveland.demon.co.uk> writes:
  780. > What this means is that you must be #including MacTCPCommonTypes.h
  781. > more than once, either directly or indirectly. Now all you have to do
  782. > is track it down...
  783. > Lawrence "This would never happen with Modula-2" D'Oliveiro
  784. > Usenet DBcc specialist
  785.  
  786. Or use #pragma once at the top of MacTCPCommonTypes.h
  787. - --
  788. Sean Michael White
  789. moonshadow@cs.stanford.edu    "I'm bein' followed by a Moonshadow"
  790.  
  791.  
  792. +++++++++++++++++++++++++++
  793.  
  794. From: davidj@daveland.demon.co.uk (David Johnston)
  795. Date: 29 Sep 92 17:25:22 GMT
  796. Organization: Daveland Developments
  797.  
  798. In article <de19-280992115841@mac19-pg2.umd.edu> Dana S Emery,
  799. de19@umail.umd.edu writes:
  800. >Oh, BTW, the symptom was a spurious link failure, referencing an
  801. >(undefined) external symbol which n'exist pas, either in my code or in
  802. >symantec's.
  803. >
  804.  
  805.  Yep, the problem seems to be related to trying to compile stuff
  806.  from other versions of Think (I'm on 5.02). It falls over at
  807.  the first typedef in rather ill-defined circumstances. The header
  808.  file certainly wasn't included twice since I added conditionals
  809.  to prevent that.
  810.  
  811. - -----------------------------------------------------------------
  812. David Johnston:  davidj@daveland.demon.co.uk (Home IP connection)
  813. - -----------------------------------------------------------------
  814.  
  815. ---------------------------
  816.  
  817. From: ramirez@mcclb0.med.nyu.edu
  818. Subject: Postscript downloading.
  819. Organization: NYU Medical Center, New York, NY 10016, USA
  820. Date: Sat, 26 Sep 1992 22:12:03 GMT
  821.  
  822. Hello all,
  823.  
  824.     I am looking for the source code (C, C++ or Pascal) to download a
  825. PostScript file to a Laserwriter II.  I need to be able to parse the header
  826. (%%) Fields.  I need to get the name of the machine that created it and the
  827. number of pages.
  828.  
  829.     I would also appreciate if someone recomends some documentation that
  830. explains how to do this.
  831.  
  832. Thanks in advance.
  833. Edwin Ramirez.
  834.  
  835. +++++++++++++++++++++++++++
  836.  
  837. From: zaphod@bluemoon.rn.com (Peter Bierman)
  838. Organization: Blue Moon BBS ((614) 868-998[024])
  839. Date: Sat, 26 Sep 92 22:42:36 EDT
  840.  
  841. ramirez@mcclb0.med.nyu.edu writes:
  842.  
  843. >     I am looking for the source code (C, C++ or Pascal) to download a
  844. > PostScript file to a Laserwriter II.  I need to be able to parse the header
  845. > (%%) Fields.  I need to get the name of the machine that created it and the
  846. > number of pages.
  847.  
  848. I don't know if this helps, but I remember reading somewhere that the LW 
  849. driver parses out something like "EnamulatorFont" or some name of a font 
  850. that  when it encounters, it will send as postscript to the printer.
  851.  
  852. The cool thing about this was that you could use Font/DA mover and resedit 
  853. to make a copy of something like monaco and rename it the name of this 
  854. trigger font, and then just print postscript straight from any word 
  855. processor, or printing code.
  856.  
  857.  
  858. - ---
  859. The opinions I express are rarely my own, because my own are far too
  860. outragous to post here.
  861.  
  862. IntNet:zaphod@bluemoon.use.com   FutureNet: #33@#10
  863. The Metropolis (614)-846-1911
  864. - ---
  865.  
  866. +++++++++++++++++++++++++++
  867.  
  868. From: d88-jwa@dront.nada.kth.se (Jon Wtte)
  869. Date: 27 Sep 92 09:34:05 GMT
  870. Organization: Royal Institute of Technology, Stockholm, Sweden
  871.  
  872. > zaphod@bluemoon.rn.com (Peter Bierman) writes:
  873.  
  874.    I don't know if this helps, but I remember reading somewhere that the LW 
  875.    driver parses out something like "EnamulatorFont" or some name of a font 
  876.    that  when it encounters, it will send as postscript to the printer.
  877.  
  878. Wasn't the name "PostScript Escape" ?
  879.  
  880. - -- 
  881. Jon W{tte, h+@nada.kth.se, Sweden, Phone +46-8-107069
  882.  
  883. "From now on, I think I'll re-label the EQ on the
  884.  desk as Fizz and Wobble, rather than HF and LF."
  885.  
  886. ---------------------------
  887.  
  888. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  889. Subject: popup menus in non-system font
  890. Date: 10 Sep 92 21:40:27 GMT
  891. Organization: Computer Science Dept, QMW, University of London
  892.  
  893. Well, the last time I asked about this everyone was very
  894. helpful, so here goes again.
  895.  
  896. I want a popup menu to appear in a non-system font and size.
  897. There's something about this in the Q&A stack, so I followed
  898. Apple's advice. My code looks like this:
  899.  
  900. SysFontFam = (*v.options)->menuFont;
  901. SysFontSize = (*v.options)->menuSize;
  902. LastSPExtra = CurFMInput = -1;
  903.  
  904. then PopUpMenuSelect, then reset SysFontFam and SysFontSize and
  905. invalidate the other two globals again.
  906.  
  907. Now, this works a treat. Until, that is, I run an app like
  908. MSWord (are there any?) or even, I am told, MacWrite IIJ. Then
  909. (and sometimes for no apparent reason), although the font
  910. changes for the popup, the size doesn't: it stays at 12 point.
  911. Checking with MacsBug, SysFontSize is set to 9.
  912.  
  913. The problem persists after running MSWord, even after quitting
  914. it. Sometimes it will then go away again, but more often it
  915. persists until I reboot.
  916.  
  917. All help gratefully acknowledged... please?
  918.  
  919. Jeremy
  920.  
  921. +++++++++++++++++++++++++++
  922.  
  923. From: engber@ils.nwu.edu (Mike Engber)
  924. Date: 11 Sep 92 15:25:31 GMT
  925. Organization: The Institute for the Learning Sciences
  926.  
  927.  
  928. Yes, it seems that certain applications change the window manager's
  929. font setting and don't restore them. Leonard Rosenthal told me
  930. about this. The workaround he suggested was to reset them myself.
  931. After playing around with it a while I discovered that you had
  932. to reset them in both the window manager port AND the color window
  933. manager port (if colorQD is avail) - or under some circumstances
  934. (which I can't recall) there are problems.
  935.  
  936. Anyway, here is my version of PopUpMenuSelect (written in THINK C)
  937. which let's you specify that you want the menu popped up in the
  938. current port's font and size.
  939.  
  940. - -ME
  941.  
  942. - ---
  943.  
  944. extern  short   SysFontFam  : 0x0BA6;
  945. extern  short   SysFontSize : 0x0BA8;
  946. extern  long    LastSpExtra : 0x0B4C;
  947. extern  Ptr     CurFMInput  : 0x0988;
  948.  
  949. long PupSelect(MenuHandle theMenu,Point popPt,short popUpItem,Boolean useWFont){
  950.         short   item;
  951.         short   oldSysFont = SysFontFam;
  952.         short   oldSysSize = SysFontSize;
  953.         GrafPtr curPort;
  954.         
  955.         GetPort(&curPort);
  956.         
  957.         /* no need to muck around if the current font is already the system font */
  958.         if(curPort->txFont==SysFontFam && curPort->txSize==SysFontSize){
  959.             useWFont = false;
  960.         }
  961.         
  962.         if(useWFont){
  963.  
  964.             {   /* this hack fixes bugs caused by programs that mess up
  965.                     the WindowMgr port (e.g. MacWrite & Word)
  966.                  */
  967.                 GrafPtr     wPort;
  968.                 SysEnvRec   theWorld;
  969.                 GetWMgrPort(&wPort);
  970.                 SetPort(wPort);
  971.                 TextSize(0);
  972.                 TextFont(0);
  973.                 if(SysEnvirons(1,&theWorld) == noErr && theWorld.hasColorQD){
  974.                     CGrafPtr    wCPort;
  975.                     GetCWMgrPort(&wCPort);
  976.                     SetPort((GrafPtr)wCPort);
  977.                     TextSize(0);
  978.                     TextFont(0);
  979.                 }
  980.                 SetPort(curPort);
  981.             }
  982.  
  983.             SysFontFam  = curPort->txFont;
  984.             SysFontSize = curPort->txSize;
  985.             LastSpExtra = -1L;
  986.             CurFMInput  = (Ptr)(-1L);
  987.             SetItemMark(theMenu,popUpItem,'%');
  988.         }else{
  989.             CheckItem(theMenu,popUpItem,true);
  990.         }
  991.         
  992.         item = PopUpMenuSelect(theMenu,popPt.v,popPt.h,popUpItem);
  993.         CheckItem(theMenu,popUpItem,false);
  994.  
  995.         if(useWFont){
  996.             SysFontSize = oldSysSize;
  997.             SysFontFam  = oldSysFont;
  998.             LastSpExtra = -1L;
  999.             CurFMInput  = (Ptr)-1L;
  1000.         }
  1001.  
  1002.     return item;
  1003. }
  1004.  
  1005. +++++++++++++++++++++++++++
  1006.  
  1007. From: alexr@apple.com (Alexander M. Rosenberg)
  1008. Date: 11 Sep 92 17:10:32 GMT
  1009. Organization: Hackers Anonymous
  1010.  
  1011. In article <1992Sep10.214027.7936@dcs.qmw.ac.uk> Jeremy Roussak,
  1012. jeremyr@dcs.qmw.ac.uk writes:
  1013. >Now, this works a treat. Until, that is, I run an app like
  1014. >MSWord (are there any?) or even, I am told, MacWrite IIJ. Then
  1015. >(and sometimes for no apparent reason), although the font
  1016. >changes for the popup, the size doesn't: it stays at 12 point.
  1017. >Checking with MacsBug, SysFontSize is set to 9.
  1018. >
  1019. >The problem persists after running MSWord, even after quitting
  1020. >it. Sometimes it will then go away again, but more often it
  1021. >persists until I reboot.
  1022.  
  1023. This is the result of some _very_ sloppy programming on the parts
  1024. of Claris, Microsoft, etc.
  1025.  
  1026. They have a custom MDEF that draws their cute little up-shift arrow
  1027. symbol and the like. MDEFs draw in the Window Manager port. They
  1028. change some values in that port and don't restore them.
  1029.  
  1030. In particular, the text size field is frequently changed to 12.
  1031. What was wrong:
  1032.  
  1033. 1.) They changed the value of a system-wide structure for a specific
  1034. purpose and didn't restore it.
  1035.  
  1036. 1A.) (Only in some applications) Instead of using a trap to change these
  1037. values, they slam them directly into the structure, despite years of
  1038. Apple recommending otherwise.
  1039.  
  1040. 2.) They typically set the font to 0 and the size to 12. This is incorrect.
  1041. The system font is 0, and the system font size is 0. Size 12 is not correct
  1042. for a Kanji system, for one.
  1043.  
  1044. 3.) Your pop-up is drawn in the Window Manager Port by the sytem supplied
  1045. MDEF. You've temporarily changed the system font and size to be the font
  1046. and size you want. It ends up being drawn in the correct font at the size
  1047. that the application slammed in in step 2, typically 12.
  1048.  
  1049. What have we learned?
  1050.  
  1051. 1.) Don't be a bad dog!
  1052.  
  1053. 2.) Save and restore all system-wide things you change unless the intent
  1054. is for the change to affect others.
  1055.  
  1056. 3.) Listen carefully to the statements that DTS has to say.
  1057.  
  1058. 4.) Save the current Window Manager port font and size and set them, via
  1059. the correct _TextFont and _TextSize traps to 0 around your call to
  1060. PopUpMenuSelect.
  1061.  
  1062. 5.) The pop-up control in System 7 was fixed this way in System 7 Release 7.1.
  1063. - ---------------------------------------------------------------------------
  1064. - -  Alexander M. Rosenberg  - INTERNET: alexr@apple.com      - Yoyodyne    -
  1065. - -  330 Waverley St., Apt B - UUCP:ucbvax!apple!alexr        - Propulsion  -
  1066. - -  Palo Alto, CA 94301     -                                - Systems     -
  1067. - -  (415) 329-8463          - Nobody is my employer so       - :-)         -
  1068. - -  (408) 974-3110          - nobody cares what I say.       -             -
  1069.  
  1070. +++++++++++++++++++++++++++
  1071.  
  1072. From: walkerj@math.scarolina.edu (Jim Walker)
  1073. Date: 11 Sep 92 04:14:44 GMT
  1074. Organization: USC  Department of Computer Science
  1075.  
  1076. In <1992Sep10.214027.7936@dcs.qmw.ac.uk> jeremyr@dcs.qmw.ac.uk (Jeremy Roussak) writes:
  1077.  
  1078. >I want a popup menu to appear in a non-system font and size.
  1079. >There's something about this in the Q&A stack, so I followed
  1080. >Apple's advice. My code looks like this:
  1081.  
  1082. >SysFontFam = (*v.options)->menuFont;
  1083. >SysFontSize = (*v.options)->menuSize;
  1084. >LastSPExtra = CurFMInput = -1;
  1085.  
  1086. >then PopUpMenuSelect, then reset SysFontFam and SysFontSize and
  1087. >invalidate the other two globals again.
  1088.  
  1089. >Now, this works a treat. Until, that is, I run an app like
  1090. >MSWord (are there any?) or even, I am told, MacWrite IIJ. Then
  1091. >(and sometimes for no apparent reason), although the font
  1092. >changes for the popup, the size doesn't: it stays at 12 point.
  1093. >Checking with MacsBug, SysFontSize is set to 9.
  1094.  
  1095. >The problem persists after running MSWord, even after quitting
  1096. >it. Sometimes it will then go away again, but more often it
  1097. >persists until I reboot.
  1098.  
  1099. Here's an answer, archived from CompuServe:
  1100.  
  1101. |Date:    Wed, Aug 19, 1992 11:32:27 AM
  1102. |Subject: #95335-PopUpMenuSelect + style
  1103. |From:    Spec Bowers 70731,3710
  1104. |To:      Ken Elston 71251,310
  1105. |
  1106. |
  1107. |Ken,
  1108. |
  1109. |It's a bug in several Microsoft products. You can program around it but it's a
  1110. |nuisance.
  1111. |
  1112. |The Window Manager's port is normally set to size 0, system standard.
  1113. |Microsoft comes along and sets it to size 12 and doesn't restore it.
  1114. |
  1115. |The technique described in previous messages for setting font and size for a
  1116. |popup menu, simply sets the system standard. Whenever a port is using size 0,
  1117. |it uses the standard size stored in the low memory globals. If the port is set
  1118. |to 12 or any other size, the default size is ignored.
  1119. |
  1120. |The cure is to set the window manager's port (WMGRPort) to size 0 before
  1121. |calling PopupMenuSelect. You'll have to save the current port, get the WMGR
  1122. |port, set the current port to be the WMGR port, set the size to 0, then
  1123. |restore the current port to the original. You probably should reverse the
  1124. |process after PopupMenuSelect returns. It is proper practice to restore port
  1125. |settings. On the other hand the proper setting for the WMGR port is 0.
  1126. |
  1127. |
  1128. |Spec Bowers
  1129. |Bowers Development
  1130. |(developers of AppMaker)
  1131.  
  1132. - --
  1133.  
  1134.  -- Jim Walker  USC Dept. of Math.  walkerj@math.scarolina.edu
  1135.  
  1136. +++++++++++++++++++++++++++
  1137.  
  1138. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  1139. Date: 26 Sep 92 23:58:45 GMT
  1140. Organization: University of Illinois at Urbana
  1141.  
  1142. In this discussion, people mentioned that if you do reset the Window
  1143. Manager's port so that the text size is 0, you should return it to the
  1144. (wrong) value that it was before, as evidently System 7.1 does. Can
  1145. anyone out there think of reasons that this would be necessary? I
  1146. would like to do this, but the code I am writing makes it pretty
  1147. impossible to reset the port before each and every call to
  1148. PopUpMenuSelect. What would I screw up by permanently changing it to
  1149. 0?
  1150.  
  1151. Thanks,
  1152.  
  1153. pr
  1154. - -- 
  1155. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  1156. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  1157. System manager - Cognitive Science Group, Beckman Institute, UIUC
  1158. Internet: resnick@cogsci.uiuc.edu
  1159.  
  1160. +++++++++++++++++++++++++++
  1161.  
  1162. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  1163. Date: 28 Sep 92 07:06:23 GMT
  1164. Organization: Computer Science Dept, QMW, University of London
  1165.  
  1166. In <Bv7MLy.EA5@news.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  1167.  
  1168. >In this discussion, people mentioned that if you do reset the Window
  1169. >Manager's port so that the text size is 0, you should return it to the
  1170. >(wrong) value that it was before, as evidently System 7.1 does. Can
  1171. >anyone out there think of reasons that this would be necessary? I
  1172. >would like to do this, but the code I am writing makes it pretty
  1173. >impossible to reset the port before each and every call to
  1174. >PopUpMenuSelect. What would I screw up by permanently changing it to
  1175. >0?
  1176.  
  1177. I started this thread, so I'll add my two-penn'orth.
  1178.  
  1179. The txSize field of the WMgrPort (and WMgrCPort, if you have
  1180. colour QD) should always (I think) be zero. Certain rogues,
  1181. notably Microsoft and Claris (who should know better :-)), set
  1182. it to the system font size in their custom MDEFs and don't
  1183. reset it.
  1184.  
  1185. It being good practice, you should probably restore any value
  1186. you ever change in a structure which doesn't belong to you.
  1187. However, I haven't done this in my INIT (Apollo) and I've been
  1188. unable to detect any adverse effects.
  1189.  
  1190. The answer to your question, though, depends on what you mean
  1191. by "permanently". Unless you can guarantee that no-one else
  1192. will change it to 12 (typically) during the execution of your
  1193. program, you can't change the value to 0 "permanently", since
  1194. (as I understand it) the WMgr(C)Port is a system-wide
  1195. structure, not one of the ones of which each app has its own
  1196. copy.
  1197.  
  1198. Why is it so difficult for you to change it before each call?
  1199. Can't you just write a sort of "glue"?
  1200.  
  1201. Jeremy
  1202.  
  1203. +++++++++++++++++++++++++++
  1204.  
  1205. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  1206. Date: 28 Sep 92 18:36:19 GMT
  1207. Organization: University of Illinois at Urbana
  1208.  
  1209. jeremyr@dcs.qmw.ac.uk (Jeremy Roussak) writes:
  1210.  
  1211. >The answer to your question, though, depends on what you mean
  1212. >by "permanently". Unless you can guarantee that no-one else
  1213. >will change it to 12 (typically) during the execution of your
  1214. >program, you can't change the value to 0 "permanently", since
  1215. >(as I understand it) the WMgr(C)Port is a system-wide
  1216. >structure, not one of the ones of which each app has its own
  1217. >copy.
  1218.  
  1219. I was thinking of changing it to 0 on initialization and on every
  1220. activate event, which should be permanent enough for me because...
  1221.  
  1222. >Why is it so difficult for you to change it before each call?
  1223. >Can't you just write a sort of "glue"?
  1224.  
  1225. The problem is that I wanted to use the popupMenuCDEF in my control
  1226. panel. Because this is a control panel, I don't get mouse-down events
  1227. when the popup menu control has been hit. All I get is a hitDev
  1228. message after the mouse has been released. That means that I can't
  1229. pre-set txSize to 0 and then unset it after the menu has popped up. So
  1230. if I reset it at initialization and whenever I get an activate event,
  1231. I figured I would be safe. I may not do it anyway, just so I can say
  1232. how horrible MS and Claris are in my "Known problems" section of the
  1233. documentation. :-)
  1234.  
  1235. Control panels are such a pain.
  1236.  
  1237. pr
  1238. - -- 
  1239. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  1240. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  1241. System manager - Cognitive Science Group, Beckman Institute, UIUC
  1242. Internet: resnick@cogsci.uiuc.edu
  1243.  
  1244. ---------------------------
  1245.  
  1246. End of C.S.M.P. Digest
  1247. **********************
  1248.